
import multiprocessing as mp
from _pytest import runner
import pytest


def job(x):
    return x**100

def multicorer():
    pool = mp.Pool()
    res = pool.map(job,range(3))
    print(res)

def multicore2():
    pool = mp.Pool()
    res = pool.apply_async(job,(3,))
    print(res.get())

def multicore3():
    pool = mp.Pool(processes=3)
    res_multi = [pool.apply_async(job,(i,)) for i in range(3)]
    print([res.get() for res in res_multi])

def job2(q,a):
    q.put(a**100)






if __name__ == '__main__':
    multicorer()
    multicore2()
    multicore3()

    queue = mp.Queue()
    p1 = mp.Process(target=job2,args=(queue,0))
    p2 = mp.Process(target=job2,args=(queue,1))
    p3 = mp.Process(target=job2,args=(queue,2))
    p1.start()
    p2.start()
    p3.start()
    p1.join()
    p2.join()
    p3.join()
    res1 = queue.get()
    res2 = queue.get()
    res3 = queue.get()
    print(res1,res2,res3)